library(ggplot2)
library(dplyr)
t <- seq(0, 10, length.out = 400)
lambda <- 0.5
datos <- data.frame(
t = t,
densidad = dexp(t, rate = lambda),
acumulada = pexp(t, rate = lambda)
)
ggplot(datos, aes(x = t)) +
geom_line(aes(y = densidad), color = "blue", size = 1) +
geom_line(aes(y = acumulada), color = "darkgreen", size = 1, linetype = "dashed") +
labs(
title = "Densidad y función de distribución acumulada (Exponencial)",
y = "Valor",
x = "t"
) +
theme_minimal() +
theme(plot.title = element_text(size = 14, face = "bold")) +
scale_y_continuous(sec.axis = sec_axis(~., name = "F(t)", breaks = c(0, 0.5, 1)))